home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1992-3 by Jon Dart. All Rights Reserved
-
- // S_Node - base class
- // can be used to build a variety of linked data structures.
-
- #ifndef S_NODE_H
- #define S_NODE_H
-
- #include <stdlib.h>
- #include "pool.h"
-
- template <class T>
- class S_Node
- {
- public:
- S_Node( const T &stuff ) :
- contents(stuff), link(NULL) {
- }
-
- virtual ~S_Node()
- {
- }
-
- S_Node( const S_Node & source )
- :contents(source.contents), link(NULL)
- {
- }
-
- S_Node *Link() {
- return link;
- }
-
- void MakeLink(S_Node *t) {
- link = t;
- }
-
- T * Contents() {
- return &contents;
- }
-
- void Set_Contents( T *p ) {
- contents = *p;
- }
-
- void *operator new(size_t size)
- {
- return allocator.allocate(size);
- }
-
- void operator delete( void *p )
- {
- allocator.free(p);
- }
-
- static void freeAll(Boolean final = False)
- {
- allocator.freeAll(final);
- }
-
- protected:
- T contents;
- S_Node *link;
- static Pool allocator;
- };
-
- #endif
-
-